#ifndef __DAHUA_MULTICAMERAS_DEMO_MVCAMERA_H__
#define __DAHUA_MULTICAMERAS_DEMO_MVCAMERA_H__

#include "GenICam/Camera.h"
#include "GenICam/System.h"
#include "GenICam/GigE/GigECamera.h"
#include "GenICam/GigE/GigEInterface.h"
#include "GenICam/EventSubscribe.h"
#include "Memory/SharedPtr.h"
#include "MvDisplayHelper.h"

#include <string>
#include <vector>

namespace Dahua{

class IMvCameraSink
{
public:
	virtual ~IMvCameraSink() {}

public:
	virtual void onCameraDisconnect() = 0;
};

class CMvCamera
{
public:
	typedef struct _tag_NetAddressInfo_
	{
		std::string		_strIpAddr;
		std::string		_strMaskAddr;
		std::string		_strGatewayAddr;
		std::string		_strMac;

	}NetAddressInfo;

	typedef struct _tag_ParamControl_
	{
		GenICam::IAcquisitionControlPtr		_sptrAcquistionCtrl;
		GenICam::IAnalogControlPtr			_sptrAnalogCtrl;
		GenICam::IImageFormatControlPtr		_sptrImageFormatCtrl;
		GenICam::IISPControlPtr				_sptrIspCtrl;
		GenICam::IUserSetControlPtr			_sptrUserSetCtrl;
	}ParamControlSet;

	typedef Memory::TSharedPtr<ParamControlSet> ParamControlSetPtr;
	typedef std::vector<std::string> ParamVectorType;
	typedef Memory::TSharedPtr<NetAddressInfo> NetAddressInfoPtr;

public:
	CMvCamera(const GenICam::ICameraPtr& sptrCamera);
	~CMvCamera();

public:
	bool open(IMvCameraSink* pSink = NULL);

    bool isOpen();

	void close();

	bool forceIpAddress(const char* pIpAddr, const char* pMaskAddr = NULL, const char* pGatewayAddr = NULL);

	bool startDisplay(void* pShowHandle, int iShowRate = 30);

	bool stopDisplay();

	bool subscribeParamUpdate(const ParamVectorType* pParamList = NULL);

	ParamControlSetPtr getParamControl();

	NetAddressInfoPtr getGigECameraInfo();

	NetAddressInfoPtr getGigEInterfaceInfo();

private:
	void procConnectArg(const GenICam::SConnectArg& arg);

private:
	GenICam::ICameraPtr				m_sptrCamera;
	GenICam::IGigECameraPtr			m_sptrGigECamera;
	GenICam::IGigEInterfacePtr		m_sptrGigEInterface;
	ParamControlSetPtr				m_sptrParamCtrlSet;
	CMvDisplayHelperPtr				m_sptrDisplayHelper;
	IMvCameraSink*					m_pMvCameraSink;
};

typedef Memory::TSharedPtr<CMvCamera> CMvCameraPtr;

} // namespace Dahua

#endif // __DAHUA_MULTICAMERAS_DEMO_MVCAMERA_H__
